import React from 'react'
// withrouter 只有在react-douter-dom@5存在，最新的6版本已经砍掉了这个api
import {withRouter} from "react-router-dom" // withrouter 可以让没有路由信息对象的组件里拥有路由信息对象
function Shortitem(props) {
 
   const godetail = (id)=>{
        console.log(props.history);
        props.history.push({
            pathname:"/detail/" + id
          })
   }
  return (
    <div>
       {
           props.arr &&  <div  onClick={()=>godetail(props.arr.id)}>
                                <h3>{props.arr.tit}</h3>
                                <img src={props.arr.img} alt="" />
                         </div>
       }
        {/* <div key={index} onClick={()=>godetail(item.id)}>
               <h3>{item.tit}</h3>
               <img src={item.img} alt="" />
          </div> */}
    </div>
  )
}

export default withRouter(Shortitem)